package com.jiukuaidao.zhulin.module.commodity.presenter;

import com.jiukuaidao.library.net.MyRetroCallBack;
import com.jiukuaidao.zhulin.api.ApiGetGoodsComments;
import com.jiukuaidao.zhulin.data.TasksRepository;
import com.jiukuaidao.zhulin.entity.ApiGoodsCommentsInfo;
import com.jiukuaidao.zhulin.module.BasePresenter;
import com.jiukuaidao.zhulin.module.commodity.contract.GoodsCommentsContract;

/**
 * Created by wangyijie on 16.8.3.
 */
public class GoodsCommentsPresenter extends BasePresenter<GoodsCommentsContract.View, TasksRepository> implements GoodsCommentsContract.Presenter {

    public GoodsCommentsPresenter(TasksRepository repository, GoodsCommentsContract.View view) {
        super(repository, view);
    }


    /**
     *
     */
    @Override
    public void start() {
        this.loadGoodsComment(GoodsCommentsContract.REFRESH);
    }

    /**
     * 获取商品评论数据
     *
     * @param dataAction
     */
    @Override
    public void loadGoodsComment(final int dataAction) {

        mRepository.loadData(new ApiGetGoodsComments(mView.getGoodsId(), mView.getPageIndex(), new MyRetroCallBack<ApiGoodsCommentsInfo>() {

            @Override
            public void onSuccess(ApiGoodsCommentsInfo result, String errorCode, String msg) {
                mView.getGoodsCommentSuc(result, dataAction);
            }

            @Override
            public void onFail(ApiGoodsCommentsInfo result, String errorCode, String msg) {

            }

            @Override
            public void onError(Throwable t, int resCode, String msg) {

            }
        }));
    }
}
